#from selenium import selenium
#import urllib
#import re
#
#driver = "hello"
##Open up gmail
#gmailInboxStr = "https://mail.google.com/mail/?shva=1#inbox"
#gmailPage = "https://mail.google.com"
#
#mailNums = []
#
#def runGmail():
#    """
#    Open up a new browser window with firefox and open gmail
#    """
#    #Get an instance of firefox
#    global driver
#    driver = webdriver.Firefox()
#    driver.get(gmailPage)
#
#def userLoggedIn():
#    """
#    Once user has logged in run this once
#    """
#    global mailNums, driver
#    driver.get(gmailInboxStr)
#    mailNums = listOfMailNumbers()
#    
#def openMail(num):
#    """
#        Defines which mail we want to open
#    """
#    global mailNums, driver 
#
#    mailStr = gmailInboxStr + "/" + mailNums[num]
#    driver.get(mailStr)
#
#def backToInbox():
#    """
#    Sends the user back to their inbox
#    """
#    global driver
#    driver.get(gmailInboxStr)
#
#def listOfMailNumbers():
#    global driver
#    finalList = []
#
#    source = driver.get_page_source()
#    strSource = source.encode('ascii', 'ignore')
#    
#    #Starting from var VIEW_DATA until the end of the string
#    smallerSource = strSource[strSource.find("var VIEW_DATA="):]
# 
#    #For getting just where gmail has sets of 3 numbers
#    matchString = ",[\"[a-zA-Z0-9]+\",\"[a-zA-Z0-9]+\",\"[a-zA-Z0-9]+\""
#    group3numList = re.findall(matchString, smallerSource)
#    
#    #For getting these numbers from the group of three
#    #One element in group3numList is ,["0asdf322dsf","3099adsfdsa","0234234"]
#    #So for each of those items, we want to extract just one number
#    matchStr2 = "[a-zA-Z0-9]+"
#
#    
#    for group3num in group3numList:
#        numList = re.findall(matchStr2, group3num)
#        #numList has the 3 numbers we want, the first 
#        #definitely being a menu for the gmail page
#        finalList.append(numList[0])
#
#    return finalList
#
#if __name__ == '__main__':
#    """
#    Use case
#    
#    runGmail()
#    #Wait until user logs in
#    userLoggedIn()
#    openMail(1)
#    openMail(10)
#    backToInbox()
#    """
#    print ("hi")